<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
</head>

<body>

    <div id="contain">
        <form @submit.prevent="demo">
            <label for="name">名字:</label>
            <input type="text" id="name" v-model="name">
            <br>
            <label for="password">密码:</label>
            <input type="text" id="password">
            <br>
            <label>性别:</label>
            男<input type="radio" name="sex" value="男" v-model="sex">
            女<input type="radio" name="sex" value="女" v-model="sex">
            <br>
            年龄: <input type="number" v-model.number="age">
            <br>
            爱好: <input type="checkbox" v-model="hobby" value="study">学习
            <input type="checkbox" v-model="hobby" value="game">电竞
            <br>
            城市:<select v-model="city">
                <option value="广州">广州</option>
                <option value="北京">北京</option>
                <option value="深圳">深圳</option>
                <option value="上海">上海</option>
            </select>
            <br>
            <textarea v-model.lazy="other"></textarea>
            <br>
            <input type="checkbox">同意并接受
            <br>
            <button>提交</button>
        </form>
    </div>
    <script>
        const vm = new Vue({
            el: '#contain',
            data: {
                name: '',
                password: '',
                sex: '',
                hobby: [],//多组勾选框要用数组存储,
                city: [],
                other: '',
                age: ''
            }, methods: {
                demo() { console.log(JSON.stringify(this._data)); }
            },
        });

    </script>
</body>

</html>